package desu.nya.animepersistance.model;
// Generated Jan 24, 2012 9:30:18 AM by Hibernate Tools 3.2.1.GA


import java.io.ByteArrayInputStream;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.Table;
import org.primefaces.model.DefaultStreamedContent;
import org.primefaces.model.StreamedContent;

/**
 * Cover generated by hbm2java
 */
@Entity
@Table(name="cover"
    ,catalog="animedb"
)
public class Cover  implements java.io.Serializable {

    @Id
    @GeneratedValue(strategy=IDENTITY)
    @Column(name="id", unique=true, nullable=false)
     private Long id;
    @Column(name="image")
     private byte[] image;
    @Column(name="small_image")
     private byte[] smallImage;

    public Cover() {
    }

    public Cover(byte[] image) {
       this.image = image;
    }
   
         public Long getId() {
        return this.id;
    }
    
    public void setId(Long id) {
        this.id = id;
    }
    
        public byte[] getImage() {
        return this.image;
    }
    
    public void setImage(byte[] image) {
        this.image = image;
    }

    public byte[] getSmallImage() {
        return smallImage;
    }

    public void setSmallImage(byte[] smallImage) {
        this.smallImage = smallImage;
    }
    
    public StreamedContent getStreamedImage(){
        if(image==null){
            System.out.println("IMAGE EMPTY");
            return new DefaultStreamedContent(new ByteArrayInputStream(image), "image/jpg");
        }
         StreamedContent tempStream=new DefaultStreamedContent(new ByteArrayInputStream(image), "image/jpg");
         return tempStream;
    }
}


